import { connect } from "react-redux";
import Counter from "./Counter";
import * as actions from "../../store/action";

function mapStateToProps(state) {
    return { ...state };
}

function mapDispatchToProps(dispatch) {
    return {
        handlePlus: (value) => dispatch(actions.plusAction(value)),
        handleMinus: (value) => dispatch(actions.minusAction(value)),
        handleAsyncPlus: (value, time) =>
            dispatch(actions.plusAsyncAction(value, time)),
        handleAsyncMinus: (value, time) =>
            dispatch(actions.minusAsyncAction(value, time)),
    };
}

let container = connect(mapStateToProps, mapDispatchToProps)(Counter);
export default { ...container, name: "CounterContainer" };
